<?php
namespace app\modules\pay\controllers;

use app\common\controllers\AccessController;
use app\modules\pay\services\PaymentLogService;
use app\modules\pay\services\PaymentService;
use yii\base\UserException;

/**
 * 支付
 * Class PaymentController
 * @package app\modules\user\controllers
 */
class PaymentController extends AccessController{

    //订单支付
    public function actionPay($order_id,$payment=""){
        if($result = PaymentService::pay($order_id,$payment)){
            return $result;
        }else{
            throw new UserException(PaymentService::getError());
        }
    }

    //订单状态
    public function actionStatus($order_id){
        if($result = PaymentLogService::status($order_id)){
            return $result;
        }else{
            throw new UserException(PaymentService::getError());
        }
    }

    //订单支持的支付方式
    public function actionMethod($order_id,$source=""){
        if($result = PaymentService::method($source,$order_id)){
            return $result;
        }else{
            throw new UserException(PaymentService::getError());
        }
    }
}